<?php
namespace app\install\controllers;

use yii\web\Controller;

class BaseController extends Controller{
    public $enableCsrfValidation = false;
    public $is_web=0;

    public function beforeAction($action)
    {
        $this->is_web = intval(\Yii::$app->request->post('is_web'));
        if(file_exists("../data/install.lock")){
            $result = ['result'=>0,'data'=>'已经安装'];
            echo json_encode($result);
            return false;
        }
        return parent::beforeAction($action); // TODO: Change the autogenerated stub
    }



    public function check_dir_write($path){
        if(!file_exists($path)){return false;}
        $file=$path.'write.txt';
        if(!$fp=@fopen($file,'w')){return false;}
        if(!@fwrite($fp,'write')){return false;}
        fclose($fp);
        @unlink($file);
        return true;
    }
}